package io.gitee.yxsnake.framework.config.jasypt.initializer;

import lombok.RequiredArgsConstructor;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author: snake
 * @create-time: 2024-10-23
 * @description:
 * @version: 1.0
 */
@RequiredArgsConstructor
public class CustomContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    private final String beanName;

    private final StringEncryptor stringEncryptor;
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        applicationContext.getBeanFactory().registerSingleton(beanName, stringEncryptor);
    }
}